bool isPalindrome(struct ListNode* head) {
    if (head->next == NULL)
        return true;
    struct ListNode* prev = NULL;
    struct ListNode* fast = head;
    struct ListNode* slow = head;
    int n = 0;
    while (fast)
    {
        fast = fast->next;
        n++;
        if (fast)
        {
            fast = fast->next;
            struct ListNode* temp = slow->next;
            slow->next = prev;
            prev = slow;
            slow = temp;
            n++;
        }
    }
    if (n % 2 == 0)
    {
        while (prev && slow)
        {
            if (prev->val != slow->val)
            {
                return false;
            }
            prev = prev->next;
            slow = slow->next;
        }
    }
    else
    {
        slow = slow->next;
        while (prev && slow)
        {
            if (prev->val != slow->val)
            {
                return false;
            }
            prev = prev->next;
            slow = slow->next;
        }

    }
    return true;

}